<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>删除用户</title>
<link href="${pageContext.request.contextPath}/themes/bootstrap/easyui.css"rel="stylesheet">
<link href="${pageContext.request.contextPath}/themes/icon.css"rel="stylesheet">
<script src="${pageContext.request.contextPath}/js/jquery.min.js"></script>
<script src="${pageContext.request.contextPath}/js/jquery.easyui.min.js"></script>
<script src="${pageContext.request.contextPath}/js/easyui-lang-zh_CN.js"></script>
<script type="text/javascript">
$(function() {
	//配置搜索框
	$('#findusername').searchbox({
		searcher : function(value, name) {
			var username = value;
			$('#usertable').datagrid('reload', {
				searchname : username
			});
		}
	});
	//配置删除按钮点击事件
	$('#deleteuser').bind('click',function(){
		var allchecked = $('#usertable').datagrid('getChecked').length;
		if(allchecked == 0){
			alert("请至少选择一项进行删除");
		}
		else{
			var allcheckeds = $('#usertable').datagrid('getChecked');
			var allchecks = [] ;
			$.each(allcheckeds,function(index,i){
				allchecks.push(i.userid);
			})
				$.ajax({
					type:'post',
					url:'${pageContext.request.contextPath}/deleteuser',
					data:{'allchecks':allchecks},
					dataType:'json',
					success:function(data){
						if(data=="1"){
							$.messager.alert('我的消息','删除成功','info',function(){
								$('#usertable').datagrid('reload');
							});
							
						}
					}
				})
		}
	});
	//	配置取消按钮事件
	$('#close').bind('click',function(){
		$('#usertable').datagrid('uncheckAll');
	});
	//配置数据表格
	$('#usertable').datagrid({
		url : '${pageContext.request.contextPath}/findallusers',
		columns : [ [{
			field:'ck',
			checkbox:true,
			ctrlSelect:true,

		}, {
			field : 'userid',
			title : '用户编号',
			width : 100,
			hidden : true
		}, {
			field : 'username',
			title : '用户姓名',
			width : 100
		}, {
			field : 'userphone',
			title : '用户电话',
			width : 100,
			align : 'right'
		}, {
			field : 'useraddr',
			title : '用户地址',
			width : 100,
			align : 'right'
		},] ],
		pagination : true,
		striped : true,
		rownumbers : true,
	});
	
});
</script>
</head>
<body>
	<div style="margin-bottom:30px;margin-top:20px;margin-left:30px">
			<input style="width:200px;height:30px" id="findusername" class="easyui-searchbox" data-options="prompt:'输入姓名查询信息',width:150">		
			<a  id="deleteuser" style="margin-left:80px; height:30px"  class="easyui-linkbutton" data-options="iconCls:'icon-remove'">删除</a>
			<a id="close" style="margin-left:40px; height:30px" class="easyui-linkbutton" data-options="iconCls:'icon-reload'">取消</a>
	</div>
	<table id="usertable" style="width:500px"></table>

	
</body>
</html>